'''
dionysus - a web based dialogue management framework
Copyright (C) 2011  Eugeniu Costetchi <eugeniu.costetchi (at) tudor.lu>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

Created on Feb 11, 2011
'''
import networkx
from matplotlib import pyplot

def show(plan):
    p = plan
    pos = networkx.graphviz_layout(p.graph, prog='dot')
    networkx.draw(p.graph, pos, node_size=400, node_color="orange", with_labels=True)
    pyplot.axis('equal')
    pyplot.show()

def save_plan_image(plan, figure_name):
    ''' saves the plan figure to a file called figure_name.png. '''
    p = plan
    pos = networkx.graphviz_layout(p.graph, prog='dot')
    networkx.draw(p.graph, pos, node_size=400, node_color="orange", with_labels=True)
    pyplot.axis('equal')
    pyplot.savefig(str(figure_name)+'.png')
